#include <fstream>
#include <iostream>
using namespace std;

#include "hmm.h"

int main(int argc, char* argv[])
{
  Hmm hmm;
  if (argc<3) {
    cerr << "USAGE: trainhmmwithtag input output" << endl;
    return 1;
  }
  ifstream istrm(argv[1]);
  const char* output = argv[2];
  vector<vector<pair<unsigned long, unsigned long> > *> trainingSequences;
  hmm.preProcess(istrm, trainingSequences, 1);
  hmm.trainWithTag(trainingSequences);
  hmm.saveProbs(output);
  ofstream file(output);
  for( unsigned i = 0; i < trainingSequences.size() ; i++ )
  {
      for( unsigned j = 0 ; j < (*trainingSequences[i]).size() ; j++ )
      {
          file<<hmm.getStr((*trainingSequences[i])[j].first)<<"/";
          file<<hmm.getStr((*trainingSequences[i])[j].second)<<" ";
      }
      file<<endl;
  }
}
